package sdk.webview.fmc.com.fmcsdk.check.persenter;


import sdk.webview.fmc.com.fmcsdk.base.BasePresenter;
import sdk.webview.fmc.com.fmcsdk.base.UserApi;
import sdk.webview.fmc.com.fmcsdk.check.bean.WorkHistoryBean;
import sdk.webview.fmc.com.fmcsdk.check.interfaces.WorkHistoryView;
import sdk.webview.fmc.com.fmcsdk.util.Url;
import sdk.webview.fmc.com.fmcsdk.util.UserHelper;
import sdk.webview.fmc.com.fmcsdk.util.retrofit2.observer.ResponseTransformer;
import sdk.webview.fmc.com.fmcsdk.util.retrofit2.subscriber.ResponseSubscriber;

/**
 * Created by ydm on 2017/9/14.
 */

public class WorkHistoryPersenter extends BasePresenter<WorkHistoryView> {


    public void getDetails(String id,String projId) {
        getApi(UserApi.class).apiGetHistory(getDefaultAddress() + Url.GET_HISTORY, UserHelper.getToken(), Long.valueOf(id),projId)
                .compose(new ResponseTransformer<>(this.<WorkHistoryBean>bindToLifeCycle()))
                .subscribe(new ResponseSubscriber<WorkHistoryBean>(view) {
                    @Override
                    public void success(WorkHistoryBean baseData) {
                        view.getHistory(baseData);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);

                    }

                    @Override
                    public void onRequestAgain() {

                    }
                });
    }

}
